package com.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.domain.Chunk;
import com.domain.LocalFile;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public interface LocalFileService extends IService<LocalFile> {

    @Transactional(rollbackFor = Exception.class)
    String uploadPic(MultipartFile file, Integer type) throws IOException;

    // 用于本地上传视频
    @Transactional(rollbackFor = Exception.class)
    String uploadVideo(MultipartFile file) throws IOException;

    @Transactional(rollbackFor = Exception.class)
    String uploadChunk(MultipartFile file, Chunk chunk);

    @Transactional(rollbackFor = Exception.class)
    void download(String multiFileMD5, HttpServletResponse response) throws IOException;

    @Transactional(rollbackFor = Exception.class)
    void downloadVideo(String multiFileMD5, HttpServletRequest request, HttpServletResponse response) throws IOException;

    LocalFile getLocalFileByMd5(String multiFileMD5);

    @Transactional(rollbackFor = Exception.class)
    String mergeChunk(Chunk chunk);
}
